/*
 * ObjectInlines.h
 *
 *  Created on: 2011-8-3
 *      Author: gexiao
 */

#ifndef OBJECTINLINES_H_
#define OBJECTINLINES_H_

/*
 * Store a single value in the array, and if the value isn't null,
 * note in the write barrier.
 */
INLINE void dvmSetObjectArrayElement(const ArrayObject* obj, int index,
                                     Object* val) {
}

/*
 * Field access functions. Pass in the word offset from Field->byteOffset.
 *
 * We guarantee that long/double field data is 64-bit aligned, so it's safe
 * to access them with ldrd/strd on ARM.
 *
 * The VM treats all fields as 32 or 64 bits, so the field set functions
 * write 32 bits even if the underlying type is smaller.
 */
#define BYTE_OFFSET(_ptr,_offset) ((void*)(((u1*)(_ptr))+(_offset)))

INLINE bool dvmGetFieldBoolean(const Object* obj, int offset) {
	return ((JValue*) BYTE_OFFSET(obj,offset))->z;
}

INLINE s4 dvmGetFieldInt(const Object* obj, int offset) {
	return ((JValue*) BYTE_OFFSET(obj, offset))->i;
}

INLINE s8 dvmGetFieldLong(const Object* obj, int offset) {
	return ((JValue*) BYTE_OFFSET(obj, offset))->j;
}

INLINE Object* dvmGetFieldObject(const Object* obj, int offset) {
	return ((JValue*) BYTE_OFFSET(obj, offset))->l;
}

INLINE void dvmSetFieldInt(Object* obj, int offset, s4 val) {

}

INLINE void dvmSetFieldLong(Object* obj, int offset, s8 val) {

}

INLINE void dvmSetFieldObject(Object* obj, int offset, Object* val) {

}

/*
 * Static field access functions.
 */
INLINE s4 dvmGetStaticFieldInt(const StaticField* sfield) {
	return sfield->value.i;
}

INLINE s8 dvmGetStaticFieldLong(const StaticField* sfield) {
	return sfield->value.j;
}

INLINE Object* dvmGetStaticFieldObject(const StaticField* sfield) {
	return sfield->value.l;
}

INLINE void dvmSetStaticFieldInt(StaticField* sfield, s4 val) {

}

INLINE void dvmSetStaticFieldLong(StaticField* sfield, s8 val) {

}

INLINE void dvmSetStaticFieldObject(StaticField* sfield, Object* val) {
}
#endif /* OBJECTINLINES_H_ */
